/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator;

import com.inspur.edp.bff.api.attribute.AbstractExtendActionConfig;
import com.inspur.edp.bff.api.attribute.ExtendActionAttribute;
import com.inspur.edp.bff.designtime.generator.core.VmCoreGenContext;
import com.inspur.edp.bff.designtime.generator.core.rtgen.datagenerator.FSDataGenerator;
import com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator.assemblermgr.AssemblerMgrGenerator;
import com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator.mgrImplclass.FSMgrImplGenerator;
import com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator.mgrinterface.FSMgrInterfaceGenerator;
import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.composite.CompositeGeneratorContext;
import com.inspur.edp.cef.gencommon.ReflectionUtils;
import com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.AccessorCreatorGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.EntityAccessorCreatorGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.DataManagerImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.ManagerGenerator;
import lombok.var;

import java.util.ArrayList;

public class FSMgrGenerator extends ManagerGenerator {
    private ArrayList<BaseGenerator> compositeItemGenerators;

    private VmCoreGenContext fsGenContext;

    public FSMgrGenerator(VmCoreGenContext parentContext) {
        super(parentContext);
        fsGenContext = parentContext;
    }

    @Override
    protected EntityGenerator createEntityGenerator() {
        return new FSDataGenerator(fsGenContext, fsGenContext.getVmGenContext().getVm().getMainObject());
    }

    @Override
    protected DataManagerImplGenerator createMgrImplGenerator() {
        return new FSMgrImplGenerator(getContext());
    }

    @Override
    protected AccessorCreatorGenerator createAccessorCreatorImplGenerator() {
        return new EntityAccessorCreatorGenerator(getContext());
    }

    @Override
    protected FSMgrGeneratorContext getContext() {
        return (FSMgrGeneratorContext) ((super.getContext() instanceof FSMgrGeneratorContext) ? super.getContext() : null);

    }

    @Override
    protected CompositeGeneratorContext createCompositeContext() {
        return new FSMgrGeneratorContext(fsGenContext);
    }

    @Override
    protected void addExtendCompositeItemGenerators(ArrayList<BaseGenerator> compositeItemGenerators) {

        //TODO FSMgrImplGenerator提出去后，生成顺序可能有问题
        compositeItemGenerators.add(new AssemblerGenerator(getContext()));
        //compositeItemGenerators.add(new FSMgrInterfaceGenerator(getContext()));
        //compositeItemGenerators.Add(new FSMgrImplGenerator(this.Context));
        compositeItemGenerators.add(new AssemblerMgrGenerator(getContext()));
    }
}
